package com.shopping.mall.core.module.order.entity;

import com.shopping.mall.core.module.cart.entity.Cart;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@ApiModel(description = "商品直接发起订单")
public class GoodOrder {
    public interface insert{
    }

    @NotBlank(message = "recipients can not be empty")
    @ApiModelProperty(value="收件人")
    private String recipients;
    @ApiModelProperty(value="地址名")
    private String title;
    @NotBlank(message = "address can not be empty")
    @ApiModelProperty(value="详细地址")
    private String address;
//    @NotBlank(message = "email can not be empty")
    @ApiModelProperty(value="邮箱")
    private String email;
//    @NotBlank(message = "district can not be empty")
    @ApiModelProperty(value="区")
    private String district;
//    @NotBlank(message = "recipients can not be empty")
    @ApiModelProperty(value="市")
    private String city;
//    @NotBlank(message = "recipients can not be empty")
    @ApiModelProperty(value="省")
    private String province;
//    @NotBlank(message = "recipients can not be empty")
    @ApiModelProperty(value="国家")
    private String country;
//    @NotBlank(message = "recipients c*an not be empty")
    @ApiModelProperty(value="手机号")
    private String phone;
    @ApiModelProperty(value="商品ID")
    private String goodId;
    @ApiModelProperty(value="规格ID")
    private String specificationId;
    @ApiModelProperty(value="数量")
    private Integer number;

    private String others;

    private String newCity;

    private Integer type;

    private List<String> cartIds;

    public static Order getOrder(GoodOrder goodOrder){
        Order order=new Order();
        order.setPlace(goodOrder.getCountry(),goodOrder.getProvince(),goodOrder.getCity(),goodOrder.getDistrict(),goodOrder.getAddress(),goodOrder.getTitle(),goodOrder.getEmail(),goodOrder.getRecipients(),goodOrder.getPhone(),goodOrder.getOthers(),goodOrder.getNewCity());
        return order;
    }

    public static Cart getCart(GoodOrder goodOrder){
        Cart cart=new Cart();
        cart.setGoodId(goodOrder.getGoodId());
        cart.setNumber(goodOrder.getNumber());
        cart.setSpecificationId(goodOrder.getSpecificationId());
        return cart;
    }

}
